import Vuex from "vuex";
import Vue from "vue";
Vue.use(Vuex);

// 用来存储数据
const state = {
  my_videos: [],
  my_collect: [],
  current_user: {},
};
// 响应组件中的事件
const actions = {
  getvideo(context, videos) {
    context.commit("videos", videos);
  },
  getcollect(context, videos) {
    context.commit("collect", videos);
  },
  getuser(context, user) {
    context.commit("user", user);
  },
};
// 操作数据
const mutations = {
  videos(state, videos) {
    state.my_videos = videos;
  },
  collect(state, videos) {
    state.my_collect = videos;
  },
  user(state, user) {
    state.current_user = user;
  },
};
// 用来将state数据进行加工
const getters = {};
// 新建并暴露store
export default new Vuex.Store({
  state,
  actions,
  mutations,
  getters,
});
